package com.zcl.seckill.controller;

import com.zcl.seckill.bean.SecondKillReq;
import com.zcl.seckill.service.SecondKillService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;



/**
 * @author 周成龙
 * @date 2021/1/22 15:08
 * description 秒杀活动
 **/
@RestController
@RequestMapping("/secondKill/")
public class SeckillController {
    private final static Logger logger= LoggerFactory.getLogger(SeckillController.class);

    @Autowired
    SecondKillService secondKillService;

    private volatile Boolean secondKillStopFlag=false;
    /**
     * description
      * @param secondKillReq
     * return
     * author 周成龙
     * createTime 2021/1/22 15:07
     **/
    @RequestMapping(value = "secondKill",method = RequestMethod.POST)
    public Boolean secondKill(SecondKillReq secondKillReq){
        logger.info("秒杀活动的入参："+secondKillReq.toString());
        Boolean flag=secondKillService.secondKill(secondKillReq);
        logger.info("秒杀活动的结果：秒杀"+(flag?"成功":"失败"));
        return flag;
    }

    @RequestMapping(value = "secondKill1",method = RequestMethod.POST)
    public Boolean secondKill1(SecondKillReq secondKillReq){
        logger.info("秒杀活动的入参："+secondKillReq.toString());
        Boolean flag=secondKillService.secondKill1(secondKillReq);
        logger.info("秒杀活动的结果：秒杀"+(flag?"成功":"失败"));
        return flag;
    }
}
